/**
 * 项目名称:Map
 *
 * @Author: 夏国倩
 * @Date: 2023/9/25 15:21
 * @Copyright
 */
package Map;
import java.util.Objects;

public class Student1 {
    private String name;
    private int id;

    public Student1() {
    }

    public Student1(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
    //hashCode
    //重写equals(如果学生姓名一样，表示同一个学生）
//    @Override
//    public boolean equals(Object obj){
//        if (obj==null || !(obj instanceof Student1))return  false;
//        if (obj==this)return true;
//        Student1 s=(Student1) obj;
//        return this.name.equals(s.name);
//    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student1 student1 = (Student1) o;
        return Objects.equals(name, student1.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }
}
